package com.vcredit.creditcat.enumtype;

/**
 * 贷款期限枚举
 */
public enum LoanTermUnitEnum {
	
	MONTH(1, "月"),
	DAY(2, "天"),
	TERM(3, "期");

	private Integer type;
	private String name;
	
	private LoanTermUnitEnum(Integer type, String name) {
		this.type = type;
		this.name = name;
	}
	public Integer getType() {
		return type;
	}
	public String getName() {
		return name;
	}
	
	public static String getNameByType(Integer type) {
		for(LoanTermUnitEnum termEnum : LoanTermUnitEnum.values()) {
			if(termEnum.getType().intValue() == type) {
				return termEnum.getName();
			}
		}
		return null;
	}
	
	public static Integer getTypeByName(String name) {
		for(LoanTermUnitEnum termEnum : LoanTermUnitEnum.values()) {
			if(termEnum.getName().equals(name)) {
				return termEnum.getType();
			}
		}
		return null;
	}
}
